//
//  BoundFooterView.swift
//  EasePods
//
//  Created by 李然 on 2024/5/6.
//

import UIKit

class BoundFooterView: View {
    override init(frame: CGRect) {
        super.init(frame: frame)
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func makeUI() {
        super.makeUI()
        activityIndicatorView.animating()
        let contentView = View()
        contentView.addSubview(activityIndicatorView)
        contentView.addSubview(titleLabel)
        self.addSubview(contentView)
        
        titleLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.leading.equalTo(activityIndicatorView.snp.trailing).offset(8.0)
            make.trailing.equalToSuperview()
            make.bottom.lessThanOrEqualToSuperview()
        }

        activityIndicatorView.snp.makeConstraints { make in
            make.leading.equalToSuperview()
            make.centerY.equalToSuperview()
            make.bottom.lessThanOrEqualToSuperview()
        }
        
        contentView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview()
        }
    }

    public func startAnimating() {
        activityIndicatorView.startAnimating()
    }

    public func stopAnimating() {
        activityIndicatorView.stopAnimating()
    }

    //MARK: - lazy load -

    public lazy var titleLabel: Label = {
        let hitLabel = Label()
        hitLabel.font = Fonts.systemFont(ofSize: 12)
        hitLabel.textColor = R.color.common_3_text()
        return hitLabel
    }()

    public lazy var activityIndicatorView: IndicatorView = {
        let view = IndicatorView()
        view.image = R.image.ic_common_loading()
        return view
    }()
    
}
